package com.corning.product.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.corning.product.entity.HosCategoryEntity;
import com.corning.product.service.HosCategoryService;
import com.corning.common.utils.PageUtils;
import com.corning.common.utils.R;



/**
 * 
 *
 * @author wtt
 * @email 1239115389@qq.com
 * @date 2022-03-20 15:07:32
 */
@RestController
@RequestMapping("product/hoscategory")
public class HosCategoryController {
    @Autowired
    private HosCategoryService hosCategoryService;

    /**
     * 列表
     */
    @RequestMapping("/list")

    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = hosCategoryService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{cateId}")

    public R info(@PathVariable("cateId") Integer cateId){
		HosCategoryEntity hosCategory = hosCategoryService.getById(cateId);

        return R.ok().put("hosCategory", hosCategory);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public R save(@RequestBody HosCategoryEntity hosCategory){
		hosCategoryService.save(hosCategory);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody HosCategoryEntity hosCategory){
		hosCategoryService.updateById(hosCategory);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")

    public R delete(@RequestBody Integer[] cateIds){
		hosCategoryService.removeByIds(Arrays.asList(cateIds));

        return R.ok();
    }

}
